package com.elinshaw.netty4.config


import groovy.util.logging.Slf4j
import io.netty.channel.ChannelHandlerContext
import io.netty.channel.ChannelInboundHandlerAdapter

/**
 * @author Administrator
 */
@Slf4j
class ServerHandler extends ChannelInboundHandlerAdapter {

    @Override
    void channelActive(ChannelHandlerContext ctx) throws Exception {
        log.info("channelActive")
        super.channelActive(ctx)
    }

    @Override
    void channelInactive(ChannelHandlerContext ctx) throws Exception {
        log.info("channelInactive")
    }

    @Override
    void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        log.info("channelRead")
        super.channelRead(ctx, msg)
    }

    @Override
    void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
        log.info("channelReadComplete")
        super.channelReadComplete(ctx)
    }

    @Override
    void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        log.info("exceptionCaught")
        ctx.channel().close()
    }

}
